<?php
class Access{
    public function index($params){
        $ci =& get_instance();
        
        require_once 'levels.php';
        
        
        $class  = $ci->router->fetch_class();
        $method = $ci->router->fetch_method();
                
        if (in_array($class, $role[0]) || $ci->session->userdata('role') == $adminRole){
            //These pages do not need to be authorised
            return;
        }
                
        if ($ci->session->userdata('logged_in') == FALSE){
            redirect(base_url()."home/login");
        }
        
        if ($ci->session->userdata('role') == 1){
            if (!in_array($class, $role[1])){
                redirect(base_url()."home/not_allowed");
            }
        }
        
        if ($ci->session->userdata('role') == 2){
            if (!in_array($class, $role[1]) && !in_array($class, $role[2])){
                redirect(base_url()."home/not_allowed");
            }
        }
        
    }
}